package response

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

//封装统一的请求返回格式

//封装好的响应  其中code一般是业务代码
func Response(c *gin.Context, httpStatus int, code int, data gin.H, msg string) {
	c.IndentedJSON(httpStatus, gin.H{
		"code": code,
		"data": data,
		"msg":  msg,
	})
}
func Success(c *gin.Context, data gin.H, msg string) {
	Response(c, http.StatusOK, 200, data, msg)
}
func Failed(c *gin.Context, data gin.H, msg string) {
	Response(c, http.StatusOK, 400, data, msg)
}
